package com.tensai.study.java.basic.algorithm;

import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;

import java.util.concurrent.atomic.AtomicLong;

/**
 * 素数
 *
 * @author Tensai
 */
@Slf4j
public class PrimeTest {

	public static boolean isPrime1(long x) {
		int j;
		for (j = 2; j <= Math.sqrt(x); j++) {
			if (x % j == 0) {
				break;
			}
		}
		if (j > Math.sqrt(x)) {
			log.info("true");
			return true;
		}
		log.info("false");
		return false;
	}

	public static void main(String[] args) {
		AtomicLong s = new AtomicLong(1);
		Flux.range(2, 10)
//				.filter(PrimeTest::isPrime1)
				.subscribe(it -> {
					s.set(s.get() * it);
					log.info("s={},it={}", s.get(), it);
				});

		for (; ; ) {
		}
	}
}
